//
//  TopTitleView.swift
//  MoyoungDevice
//
//  Created by 易先生 on 2022/8/26.
//

import UIKit
import MYModule

open class TopTitleView: View {
    
    public override func makeUI() {
        super.makeUI()
        
        self.addSubview(titleLabel)
        self.addSubview(detailLabel)
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(10)
            make.leading.equalToSuperview().offset(20)
            make.trailing.equalToSuperview().offset(-20)
        }
        
        detailLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(20)
            make.leading.equalToSuperview().offset(20)
            make.trailing.equalToSuperview().offset(-20)
            make.bottom.equalToSuperview()
        }
    }

    public func updateTitleAndDetailSpec(spec:CGFloat) {
        detailLabel.snp.updateConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(spec)
        }
    }
    
    public func configTitle(title:String,detail:String = "") {
        titleLabel.text = title
        detailLabel.text = detail
    }
    
    private lazy var titleLabel: Label = {
        let titleLabel = Label()
        titleLabel.textColor = UIColor.assist_222222
        titleLabel.font = Fonts.systemFont(ofSize: 32, weight: .medium)
        titleLabel.numberOfLines = 0
        return titleLabel
    }()
    
    public lazy var detailLabel: Label = {
        let detailLabel = Label()
        detailLabel.textColor = UIColor.assist_A9A9A9
        detailLabel.font = Fonts.systemFont(ofSize: 12)
        detailLabel.numberOfLines = 0
        return detailLabel
    }()
}
